Option Explicit

Dim oFS, oDDF, oDll, sPdb
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oDDF = oFS.CreateTextFile(WScript.Arguments(0) + ".ddf", true)

oDDF.WriteLine ";"
oDDF.WriteLine ".Set CabinetNameTemplate=" + WScript.Arguments(0) + ".wsp"
oDDF.WriteLine ".set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory"
oDDF.WriteLine ".Set CompressionType=MSZIP;** All files are compressed in cabinet files"
oDDF.WriteLine ".Set UniqueFiles='ON'"
oDDF.WriteLine ".Set Cabinet=on"
oDDF.WriteLine ".Set DiskDirectory1=."
EnumFolder oFS.GetFolder(WScript.Arguments(1) + "TEMPLATE"), "TEMPLATE"
Set oDll = oFs.GetFile(WScript.Arguments(2))
oDDF.WriteLine """" + oDll.Path + """" + vbTab + """" + oDll.Name + """"
sPdb = oDll.ParentFolder.Path + "\" + oFs.GetBaseName(oDll.Path) + ".pdb"
if oFs.FileExists(sPdb) then oDDF.WriteLine """" + sPdb + """" + vbTab + """" + oFs.GetBaseName(oDll.Path) + ".pdb"""
oDDF.WriteLine """" + oFS.GetAbsolutePathName(WScript.Arguments(1) + "manifest.xml") + """" + vbTab + """" + "manifest.xml"""
oDDF.WriteLine ";*** <the end>"
oDDF.Close

sub EnumFolder(oFolder, sRelativePath)    
    dim oSub, oFile
    if (sRelativePath = "TEMPLATE") then sRelativePath = ""
    if (sRelativePath = "FEATURES") then sRelativePath = ""    
    if (sRelativePath = "SiteTemplates") then sRelativePath = ""
    if (sRelativePath <> "") then sRelativePath = sRelativePath + "\"
    for each oFile in oFolder.Files
        oDDF.WriteLine """" + oFile.Path + """" + vbTab + """" + sRelativePath + oFile.Name + """"
    next
    for each oSub in oFolder.SubFolders
        if oSub.Name <> ".svn" then EnumFolder oSub, sRelativePath + oSub.Name
    next
end sub